﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace ContosoUniversity.Models
{
    public class Student
    {
        public int ID { get; set; }

        [Display(Name ="Last Name")]
        [StringLength(10, MinimumLength =1, ErrorMessage = "最少1个字，最长10个字")]
        [RegularExpression(@"^[A-Z]+[a-zA-Z""'\s-]*$", ErrorMessage = "首字母必须大写，并且只能输入字母")]
        public string LastName { get; set; }

        [Display(Name ="First Name")]
        [Required(ErrorMessage = "不能为空")]
        [StringLength(10, ErrorMessage = "First name cannot be longer than 10 characters.")]
        [RegularExpression(@"^[A-Z]+[a-zA-Z""'\s-]*$", ErrorMessage = "首字母必须大写，并且只能输入字母")]
        [Column("FirstName")]
        public string FirstMidName { get; set; }

        [Display(Name = "Enrollment Date")]
        [DataType(DataType.Date)]
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
        public DateTime EnrollmentDate { get; set; }

        [DataType(DataType.EmailAddress)]
        [EmailAddress(ErrorMessage = "Email格式不正确")]
        public string EmailAddress { get; set; }

        [Display(Name ="Full Name")]
        public string FullName { get { return FirstMidName + " " + LastName; } }

        [StringLength(2)]
        public string Sceret { get; set; }

        public ICollection<Enrollment> Enrollments { get; set; }
    }
}
